import store from '@/store';

interface DragBlock {
  show: boolean;
  width?: number;
  height?: number;
  initMouseX?: number;
  initMouseY?: number;
  img?:string
}

export const useDragSeriesStore = defineStore('dragSeries', () => {
  const dragBlock = ref<DragBlock>({ show: false });
  const dragSeriesId = ref<number>()
  const setDragBlock = async (db: DragBlock): Promise<void> => {
    dragBlock.value = db;
    return Promise.resolve();
  };
  const setDragSeriesId = async (seriesId: number): Promise<void> => {
    dragSeriesId.value = seriesId;
    return Promise.resolve();
  };
  const clearDragBlock = async (): Promise<void> => {
    // dragBlock.value = { show: false };
    dragBlock.value.show = false;
    return Promise.resolve();
  };
  const clearSeriesId = async (): Promise<void> => {
    dragSeriesId.value = undefined;
    return Promise.resolve();
  };
  return {
    dragBlock,
    dragSeriesId,
    setDragBlock,
    setDragSeriesId,
    clearDragBlock,
    clearSeriesId
  };
});

export default useDragSeriesStore;
// 非setup
export function useDragSeriesHook() {
  return useDragSeriesStore(store);
}
